package com.dawnling.rtspclientdemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.SurfaceView;
import android.view.View;

import com.aaronhan.rtspclient.RtspClient;

//https://github.com/htwahzs/Rtsp-Android-Client
//https://blog.csdn.net/xundh/article/details/85218869
//并没啥用  播放不出来
public class MainActivity extends AppCompatActivity {

    private SurfaceView mSurfaceView;
    private RtspClient mRtspClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mSurfaceView = findViewById(R.id.surfaceView);
        //创建client，需要传入一个SurfaceView作为显示
        String host = "rtsp://27.158.58.94:26022/user=admin&password=&channel=1&stream=1.sdp";
        mRtspClient = new RtspClient(host);
        mRtspClient.setSurfaceView(mSurfaceView);
        //开始显示
        mRtspClient.start();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //关闭,请在Activity销毁时调用此方法
        //在UDP模式下即使销毁Activity某些RTSP服务器也会继续发送报文
        mRtspClient.shutdown();
    }
}
